/**
 * 文件名：SysUserController.java
 * 创建时间：Jul 8, 20091:14:38 PM
 */
package com.lane.sidecn.security.web;

import com.lane.core.web.BaseController;
import com.lane.sidecn.security.model.SysUser;
import com.lane.sidecn.security.service.SysUserManager;

/**
 * @author 忽吉烈
 *
 */
public class SysUserController extends BaseController {
	private SysUserManager userManager;
	private SysUser user;
	
	/**
	 * 添加用户
	 */
	public void addUser()
	{
		try {
			user.setEnabled(1);
			userManager.save(user);
			printMessage("addSuccess");
		} catch (Exception e) {
			e.printStackTrace();
			printMessage("addFail");
		}
		
	}
	
	public void addResource() throws Exception
	{
		SysUser user = userManager.findUniqueBy("user_id", 1);
		user.getRoles();
	}
	
	/**
	 * 删除用户
	 */
	public void delUser()
	{
		userManager.removeById(user.getUser_id());
		printMessage("delSuccess");
	}
	
	/**
	 * 更新用户
	 */
	public void updateUser()
	{
		try {
			userManager.save(user);
			printMessage("updateSuccess");
		} catch (Exception e) {
			e.printStackTrace();
			printMessage("updateFail");
		}
	}

	public SysUserManager getUserManager() {
		return userManager;
	}

	public void setUserManager(SysUserManager userManager) {
		this.userManager = userManager;
	}

	public SysUser getUser() {
		return user;
	}

	public void setUser(SysUser user) {
		this.user = user;
	}
}
